home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / CTBUtilities.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  6KB  |  219 lines

  1. /*
  2.      File:        CTBUtilities.h
  3.  
  4.      Contains:    Communications Toolbox Utilities interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __CTBUTILITIES__
  19. #define __CTBUTILITIES__
  20.  
  21. #ifndef __MEMORY__
  22. #include <Memory.h>
  23. #endif
  24. #ifndef __DIALOGS__
  25. #include <Dialogs.h>
  26. #endif
  27. #ifndef __APPLETALK__
  28. #include <AppleTalk.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT_SUPPORTED
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_ALIGN_SUPPORTED
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. #if FOR_SYSTEM7_ONLY
  44.  
  45. enum {
  46.                                                                 /*    version of Comm Toolbox Utilities    */
  47.     curCTBUVersion                = 2,                            /*    Error codes/types    */
  48.     ctbuGenericError            = -1,
  49.     ctbuNoErr                    = 0
  50. };
  51.  
  52. typedef OSErr CTBUErr;
  53.  
  54. enum {
  55.     chooseDisaster                = -2,
  56.     chooseFailed                = -1,
  57.     chooseAborted                = 0,
  58.     chooseOKMinor                = 1,
  59.     chooseOKMajor                = 2,
  60.     chooseCancel                = 3
  61. };
  62.  
  63. typedef unsigned short ChooseReturnCode;
  64.  
  65. enum {
  66.     nlOk                        = 0,
  67.     nlCancel                    = 1,
  68.     nlEject                        = 2
  69. };
  70.  
  71. typedef unsigned short NuLookupReturnCode;
  72.  
  73. enum {
  74.     nameInclude                    = 1,
  75.     nameDisable                    = 2,
  76.     nameReject                    = 3
  77. };
  78.  
  79. typedef unsigned short NameFilterReturnCode;
  80.  
  81. enum {
  82.     zoneInclude                    = 1,
  83.     zoneDisable                    = 2,
  84.     zoneReject                    = 3
  85. };
  86.  
  87. typedef unsigned short ZoneFilterReturnCode;
  88.  
  89. enum {
  90.                                                                 /*    Values for hookProc items        */
  91.     hookOK                        = 1,
  92.     hookCancel                    = 2,
  93.     hookOutline                    = 3,
  94.     hookTitle                    = 4,
  95.     hookItemList                = 5,
  96.     hookZoneTitle                = 6,
  97.     hookZoneList                = 7,
  98.     hookLine                    = 8,
  99.     hookVersion                    = 9,
  100.     hookReserved1                = 10,
  101.     hookReserved2                = 11,
  102.     hookReserved3                = 12,
  103.     hookReserved4                = 13,                            /*    "virtual" hookProc items    */
  104.     hookNull                    = 100,
  105.     hookItemRefresh                = 101,
  106.     hookZoneRefresh                = 102,
  107.     hookEject                    = 103,
  108.     hookPreflight                = 104,
  109.     hookPostflight                = 105,
  110.     hookKeyBase                    = 1000
  111. };
  112.  
  113. /*    NuLookup structures/constants    */
  114. struct NLTypeEntry {
  115.     Handle                             hIcon;
  116.     Str32                             typeStr;
  117. };
  118. typedef struct NLTypeEntry NLTypeEntry;
  119.  
  120. typedef NLTypeEntry NLType[4];
  121. struct NBPReply {
  122.     EntityName                         theEntity;
  123.     AddrBlock                         theAddr;
  124. };
  125. typedef struct NBPReply NBPReply;
  126.  
  127. typedef pascal short (*DialogHookProcPtr)(short item, DialogPtr theDialog);
  128. typedef pascal short (*NameFilterProcPtr)(EntityName *theEntity);
  129. typedef pascal short (*ZoneFilterProcPtr)(ConstStr32Param theZone);
  130.  
  131. #if GENERATINGCFM
  132. typedef UniversalProcPtr DialogHookUPP;
  133. typedef UniversalProcPtr NameFilterUPP;
  134. typedef UniversalProcPtr ZoneFilterUPP;
  135. #else
  136. typedef DialogHookProcPtr DialogHookUPP;
  137. typedef NameFilterProcPtr NameFilterUPP;
  138. typedef ZoneFilterProcPtr ZoneFilterUPP;
  139. #endif
  140.  
  141. enum {
  142.     uppDialogHookProcInfo = kPascalStackBased
  143.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  144.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  145.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogPtr))),
  146.     uppNameFilterProcInfo = kPascalStackBased
  147.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  148.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(EntityName *))),
  149.     uppZoneFilterProcInfo = kPascalStackBased
  150.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  151.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConstStr32Param*)))
  152. };
  153.  
  154. #if GENERATINGCFM
  155. #define NewDialogHookProc(userRoutine)        \
  156.         (DialogHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDialogHookProcInfo, GetCurrentArchitecture())
  157. #define NewNameFilterProc(userRoutine)        \
  158.         (NameFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppNameFilterProcInfo, GetCurrentArchitecture())
  159. #define NewZoneFilterProc(userRoutine)        \
  160.         (ZoneFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppZoneFilterProcInfo, GetCurrentArchitecture())
  161. #else
  162. #define NewDialogHookProc(userRoutine)        \
  163.         ((DialogHookUPP) (userRoutine))
  164. #define NewNameFilterProc(userRoutine)        \
  165.         ((NameFilterUPP) (userRoutine))
  166. #define NewZoneFilterProc(userRoutine)        \
  167.         ((ZoneFilterUPP) (userRoutine))
  168. #endif
  169.  
  170. #if GENERATINGCFM
  171. #define CallDialogHookProc(userRoutine, item, theDialog)        \
  172.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDialogHookProcInfo, (item), (theDialog))
  173. #define CallNameFilterProc(userRoutine, theEntity)        \
  174.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppNameFilterProcInfo, (theEntity))
  175. #define CallZoneFilterProc(userRoutine, theZone)        \
  176.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppZoneFilterProcInfo, (theZone))
  177. #else
  178. #define CallDialogHookProc(userRoutine, item, theDialog)        \
  179.         (*(userRoutine))((item), (theDialog))
  180. #define CallNameFilterProc(userRoutine, theEntity)        \
  181.         (*(userRoutine))((theEntity))
  182. #define CallZoneFilterProc(userRoutine, theZone)        \
  183.         (*(userRoutine))((theZone))
  184. #endif
  185. extern pascal CTBUErr InitCTBUtilities(void );
  186.  
  187. extern pascal short CTBGetCTBVersion(void );
  188.  
  189. extern pascal short StandardNBP(Point where, ConstStr255Param prompt, short numTypes, NLType typeList, NameFilterUPP nameFilter, ZoneFilterUPP zoneFilter, DialogHookUPP hook, NBPReply *theReply);
  190.  
  191. extern pascal short CustomNBP(Point where, ConstStr255Param prompt, short numTypes, NLType typeList, NameFilterUPP nameFilter, ZoneFilterUPP zoneFilter, DialogHookUPP hook, long userData, short dialogID, ModalFilterUPP filter, NBPReply *theReply);
  192.  
  193. #if OLDROUTINENAMES
  194. #define NuLookup(where, prompt, numTypes, typeList, nameFilter, zoneFilter,    \
  195. hook, theReply)                                                                \
  196. StandardNBP(where, prompt, numTypes, typeList, nameFilter, zoneFilter,         \
  197. hook, theReply)
  198. #define NuPLookup(where, prompt, numTypes, typeList, nameFilter,                 \
  199. zoneFilter, hook, userData, dialogID, filter, theReply)                        \
  200. CustomNBP(where, prompt, numTypes, typeList, nameFilter,                         \
  201. zoneFilter, hook, userData, dialogID, filter, theReply)
  202. #endif
  203. #endif
  204.  
  205. #if PRAGMA_ALIGN_SUPPORTED
  206. #pragma options align=reset
  207. #endif
  208.  
  209. #if PRAGMA_IMPORT_SUPPORTED
  210. #pragma import off
  211. #endif
  212.  
  213. #ifdef __cplusplus
  214. }
  215. #endif
  216.  
  217. #endif /* __CTBUTILITIES__ */
  218.  
  219.